<template>
  <div class="search">
    <f-form ref="form" :action="api.distributor" :form-key="this.formItem.distributorId" >
      <f-form-item label="经销商名称"  name="distributorName" dataType="${formField.dataType}"   :value="formItem.distributorName" />
      <f-form-item label="负责人"  name="userName" dataType="${formField.dataType}"   :value="formItem.userName" />
      <f-form-item label="联系电话"  name="userPhone" dataType="${formField.dataType}"   :value="formItem.userPhone" />
      <f-form-item label="创建时间"  name="createDate" dataType="${formField.dataType}"   :value="formItem.createDate" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'distributorForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          distributorId: '',
          distributorName: '',
          userName: '',
          userPhone: '',
          createDate: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.distributorId) {
          let params={
              distributorId:data.distributorId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
